using System;

namespace Skywalker.Web.Mvc.ViewComponents
{
    public class Builder<TComponent, TBuilder> : Fluently.Builder<TComponent, TBuilder>, IBuilder<TComponent>
        where TComponent : IViewComponent, new() 
        where TBuilder : Builder<TComponent, TBuilder>
    {
        IBuilder IBuilder.ViewName(string value)
        {
            return ViewName(value);
        }

        IViewComponent IBuilder.Component { get { return Component; } }

        public new TComponent Component
        {
            get { return base.Component; }
        }

        public virtual TBuilder ViewName(string value)
        {
            return SetProperty(x => x.ViewName = value);
        }

        protected new T CreateBuilder<T>() where T : IBuilder, new()
        {
            return base.CreateBuilder<T>();
        }

        protected new T ExecuteBuilder<T>(T builder, Action<T> setup) where T : IBuilder, new()
        {
            return base.ExecuteBuilder(builder, setup);
        }

        protected new T CreateAndExecuteBuilder<T>(Action<T> setup) where T : IBuilder, new()
        {
            return base.CreateAndExecuteBuilder(setup);
        }
    }
}